package com.itheima.jdbc;

import java.sql.*;

//程序耦合
//解耦：降低程序间依赖
//解耦思路：1.使用反射创建对象，避免使用new 2.读取配置文件获取创建对象全类名
public class JdbcDemo1 {
    public static void main(String[] args) throws Exception {
//        1.注册驱动2.获取连接3.获取操作数据库的预处理对象4.执行SQL得到结果集5.遍历结果集6.释放资源
//        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/eesy","root","");
        PreparedStatement pstm = conn.prepareStatement("select  * from  account");
        ResultSet rs = pstm.executeQuery();
        while (rs.next()){
            System.out.println(rs.getString("name"));
        }
        rs.close();
        pstm.close();
        conn.close();
    }
}
